package Test_11_20;
import java.util.Scanner;
public class Test2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a =scan.nextInt();
        int b =scan.nextInt();
        int sum = 0;
        for(int i=1;i<=b;i++)
        {
            if(a%i==0&&b%i==0)
                sum =i;
        }
        System.out.println(sum);
        scan.close();
    }

}
